<%#
# To change this template, choose Tools | Templates
# and open the template in the editor.
%>

<% title "Batches", false %>

<div id="page-header">
  
  <div class="page-help-section">
    
  </div>
  <div class="page-help-navigator">
    <span id="help-button">Help</span>
  </div>
  
  <span class="page-icons page_batch_icon"></span>
  <h1 class="page-name">Batches</h1>
</div>

<br/>

<div class="page-form">
  <div class="grid-top-bar">
    <div class="grid-box">
      <select id="batch_action">
        <option selected="true">Bulk Actions</option>
        <option value="delete">Move to Trash</option>
      </select>
      <input type="submit" value="Apply" class="button">
    </div>
    <div class="grid-box">
      <label><input type="checkbox" value="published" id="batch_filter_publish" onchange="filter_published_batch()"> Published only</label>
    </div>
    <div class="grid-box float-right">
      <label class="align-right"><i><%= Batch.all.count %> Batches</i></label>
    </div>
  </div>
  <table class="grid" cellspacing="0" cellpadding="0">
    <thead class="grid_header">
      <tr>
        <th class="grid_chkbox">
          <input type="checkbox"/>
        </th>
        <th class="grid_title">Title</th>
        <th class="grid_meta">State</th>
        <th class="grid_dates">
          Dates
        </th>
      </tr>
    </thead>
    <% @batches.each do |batch| %>
      <%= render :partial => "batchrow", :object => batch, :locals => {:level => 0}  %>
    <% end %>
    <tfoot class="grid_header">
      <tr>
        <th class="grid_chkbox">
          <input type="checkbox"/>
        </th>
        <th class="grid_title">Title</th>
        <th class="grid_meta">State</th>
        <th class="grid_dates">Dates</th>
      </tr>
    </tfoot>
  </table>
</div>

<script type="text/javascript">
  function filter_published_batch(){
    //alert($("input#batch_filter_publish").is(':checked'));
    if($("input#batch_filter_publish").is(':checked')) {
      $("tr.published_false").css('display', 'none');
    } else {
      $("tr.published_false").css('display', 'table-row');
    }
  }
</script>